#ifndef PAGE3_TCP_H
#define PAGE3_TCP_H

#include <QTimer>
#include <QDebug>
#include <QBuffer>
#include <QWidget>
#include <QPainter>
#include <QTcpSocket>
#include <QTcpServer>
#include <QUdpSocket>
#include <opencv4/opencv2/opencv.hpp>

namespace Ui {
class page3;
}

class page3 : public QWidget
{
    Q_OBJECT

public:
    explicit page3(QWidget *parent = nullptr);
    ~page3();

    void reload_frame_push(cv::Mat frame_pass);

    void send_data_from_client(QByteArray data_send);

signals:
    void pushbutton_page1_clicked();

    void pushbutton_page2_clicked();

    void pushbutton_page3_clicked();

    void pushbutton_page4_clicked();

private slots:
    void on_pushButton_page1_clicked();

    void on_pushButton_page2_clicked();

    void on_pushButton_page3_clicked();

    void on_pushButton_page4_clicked();

    void socket_client_Read_Data();

    void socket_client_Disconnected();

    void on_pushButton_client_Send_clicked();

    void on_pushButton_client_Connect_clicked();

    void server_New_Connect();

    void socket_server_Read_Data();

    void socket_server_Disconnected();

    void on_pushButton_server_Send_clicked();

    void on_pushButton_server_Listen_clicked();

    void on_pushButton_server_clean_clicked();

    void on_pushButton_client_clean_clicked();

    void show_push_image();

    void on_pushButton_udp_open_clicked();

    void on_pushButton_udp_push_clicked();


private:
    Ui::page3 *ui;
    QTcpServer * server;
    QTcpSocket * socket_server;
    QTcpSocket * socket_client;
    QUdpSocket * udp_socket;
    cv::Mat frame_push;
    QTimer * timer_push;
    bool is_push_frame;
};

#endif // PAGE3_TCP_H
